<?php

/*
 * Action - Looter 4$
 * 
 * +5 $
 * You may trash an Action card from your hand. If you don't, trash this.
 * When you gain this, gain two Ruins.
 */

class DeathCart extends Card implements iAction, iKingdom, iDarkAges, iLooter {

    public function __construct() {
        parent::__construct("Death Cart", 4);
        $this->undoPlay = false;
        $this->undoBuy = false;
    }
    
    public function undoParamsBuy($undoParams) {
        return array(false, $undoParams);
    }

    public function getDescription() {
        return array(
            "+5$",
            "You may trash an Action card from your hand. If you dont, trash this.",
            "When you gain this, gain two Ruins.");
    }

    public function gainThisCard(Game $game, $name = null) {
        $cards = array();
        $ruin = new Ruin();
        $c1 = $game->moveCardFromPileToPile($ruin, BoardCards, DiscardPile, $name);
        $c2 = $game->moveCardFromPileToPile($ruin, BoardCards, DiscardPile, $name);
        if ($c1)
            $cards[] = $c1;
        if ($c2)
            $cards[] = $c2;

        ScreenDisplay::addScreenMessage($game, true, "gain " . nicePrint($cards), "gains " . ScreenDisplay::$LMSG, $name);
        
        $game->setTempCard($this);
        return true;
    }

    public function play(Game $game, $isRealCard) {
        $game->addMoney(new Price(5));
        ScreenDisplay::addScreenMessage($game, true, "get 5$ ", "gets 5$");

        $playHand = $game->getPlayHand();
        $actionCards = array();
        foreach ($playHand as $card) {
            if ($card instanceof iAction) {
                $actionCards[] = $card;
            }
        }
        $actionCards = getUniqueCards($actionCards);
        if (sizeof($actionCards) == 0) {
            $game->moveCardFromPileToPile($this, PlayArea, Trash);
            ScreenDisplay::addScreenMessage($game, false, "and trash " . nicePrint($this), " and trashes " . ScreenDisplay::$LMSG);
        } else {
            $actionCards[] = new Option(1, 'None');
            $output = MySocket::GetUserReply($game, Input_ChooseOne, $actionCards, 1, 1, null, "Choose action card to trash");
            if ($output[0] == "None") {
                $game->moveCardFromPileToPile($this, PlayArea, Trash);
                ScreenDisplay::addScreenMessage($game, false, "and trash " . nicePrint($this), " and trashes " . ScreenDisplay::$LMSG);
            } else {
                $card = n2c($output[0]);
                $card = $game->moveCardFromPileToPile($card, PlayHand, Trash);
                ScreenDisplay::addScreenMessage($game, false, "and trash " . nicePrint($card), " and trashes " . ScreenDisplay::$LMSG);
            }
        }

        $game->cardActionFinished();
        return true;
    }

    public function boardSetup(Game $game) {
        $game->addRuins();
        return true;
    }

}

?>